import os
from docx import Document
import uuid
from docx.shared import Inches


class Word:
    path = input("输入图片文件夹路径:")
    # path = "C:/Users/ACLang/Desktop/报销"
    try:
        files = os.listdir(path)
        imagesPath = []
        document = Document()
        for file in files:
            if file.endswith(".png") or file.endswith(".jpg"):
                print("正在处理 " + file + " 中.....")
                imagePath = path + "\\" + file
                imagesPath.append(imagePath)
                document.add_picture(imagePath, width=Inches(6), height=Inches(4))
        uu = str(uuid.uuid4())
        document.save(uu + "报销.docx")
        input("文档在当前目录下，处理完成！")
    except:
        print("文件路径错误！")


if __name__ == '__main__':
    word = Word()
